﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="createNewTrip.aspx.cs"
    Inherits="TripLOA.GUI.secure.createNewTrip" MasterPageFile="~/GUIMaster.Master"  %>


<%@ Register Assembly="MapControl2" Namespace="MapControl2" TagPrefix="map" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register TagPrefix="TestAscx" TagName="ExampleControl" Src="~/Controllo_Ascx/ExampleTemplate.ascx"  %>
<%@ Register src="../PeriodicTripControl/PeriodicTrip.ascx" tagname="PeriodicTrip" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    
    <link href="../PeriodicTripControl/periodicTrip.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript" src="../PeriodicTripControl/periodicTrip.js"></script>
    
   <link href="../master/resourcesNew/style.css" rel="stylesheet" type="text/css" />
   
    <style type="text/css">
        table.formTable {
            width: 430px;	
        }
        td.formLabel {
        	
        }
        td.formTextbox {
        	width: 200px;
        }     
       
    </style>
    
       
         <script src="/common/geoCodingMenu/AAAGeoCodingMenu.js" type="text/javascript"></script>
         
   

    <script type="text/javascript">
        
        // Georef interactions -----------------------------------------------------------------------------
        function InsertTrip(sender)
        {
            var dep = document.getElementById("<%=DepartureAddess.ClientID %>");
            var arr = document.getElementById("<%=ArriveAddress.ClientID %>");
            var from = MapControl2.AAAUtils.createGeoLocFromGeoCodingQuery(dep.latitude, dep.longitude, dep.value);
            var to = MapControl2.AAAUtils.createGeoLocFromGeoCodingQuery(arr.latitude, arr.longitude, arr.value);
            var loamap = Sys.Application.findComponent("ctl00_ContentHomePage_map_1");
            
            if(dep.GetStatus() == GUI.AAAGeoCodingMenu.READY && arr.GetStatus() == GUI.AAAGeoCodingMenu.READY) {
                var editableTrip = loamap.getGMap().getEditableTrip();
                var vehicleCbo = $get("ctl00_ContentHomePage_ddlvehicle");
                var vehicle = loamap.getVehicleById(vehicleCbo.value);
                if (editableTrip == null)
                    loamap.setEditableTripA2BFromGeolocs([from, to], vehicle);
                else
                    switch(sender){
                        case 0:
                            editableTrip.setStart(from);
                        break;
                        case 1:
                            editableTrip.setEnd(to);
                        break;
                        case 2:
                            editableTrip.setVehicle(vehicle);
                        break;
                    }
            }
            else if(dep.GetStatus() == GUI.AAAGeoCodingMenu.ERROR || arr.GetStatus() == GUI.AAAGeoCodingMenu.ERROR)
                loamap.getGMap().clearEditableTrip();
        }
        
        function bindMapEvents()
        {
            var map_ctrl = Sys.Application.findComponent("ctl00_ContentHomePage_map_1");
            google.maps.Event.addListener(map_ctrl.getGMap(), 'tripload', onTripChange);
            google.maps.Event.addListener(map_ctrl.getGMap(), 'tripchange', onTripChange);
            google.maps.Event.addListener(map_ctrl.getGMap(), 'tripclear', onTripClear);
            
            var vehicleCbo = $get("ctl00_ContentHomePage_ddlvehicle");
            map_ctrl.setVehicleCbo(vehicleCbo);
            var dep = document.getElementById("<%=DepartureAddess.ClientID %>");
            map_ctrl.setDepBox(dep);
            var arr = document.getElementById("<%=ArriveAddress.ClientID %>");
            map_ctrl.setArrBox(arr);
        } 
        
        function onTripClear()
        {
            fBox = $get("<%=DepartureAddess.ClientID%>"); 
            tBox = $get("<%=ArriveAddress.ClientID%>");
            fBox.value = "";
            tBox.value = "";            
        }
        
        function onTripChange(trip)
        {
            var fromTextBox = $get("ctl00_ContentHomePage_DepartureAddess"); 
            var toTextBox = $get("ctl00_ContentHomePage_ArriveAddress");
            var routes = trip.getTripModel().routes;
            var start = routes[0].start;
            var end = routes[routes.length-1].end;
            fromTextBox.setGeoloc(start);
            toTextBox.setGeoloc(end);
            
            /*fromTextBox.value = routes[0].start.address;
            toTextBox.value = routes[routes.length-1].end.address;
            fromTextBox.latitude = start.lat;
            fromTextBox.longitude = start.lng;
            toTextBox.latitude = end.lat;
            toTextBox.longitude = end.lng;
            */
        }
        // -----------------------------------------------------------------------------------------------
    </script>
    <style type="text/css">
        .ajax__calendar_container
        {  
          background-color:White;
          color: Gray;
          z-index: 1000;
           
            
        }
    </style>

    <script type="text/javascript">
        
        function hide(span)
        {   
            span.style.visibility = "hidden";
            span.style.fontSize = "1pt";
        }
        
        function visible(span)
        {    
            span.style.fontSize = "10pt";
            span.style.visibility = "visible";
        }
        
        function hourvalidation(hour, span)
        {
            success = false;
                
            if (hour.length == 0)
            {
                hide(span);
            }
            else
            {
                if (hour.length == 5)
                {
                    var h = hour.substring(0, 2);
                    var min = hour.substring(3, 5);
                    var boolh = false;
                    var boolmin = false;
                    
                    boolh = (h <= 23 && h >= 0); 
                    boolmin = (min >=0 && min <= 59);
                                       
                    if (boolh && boolmin) 
                    {
                        hide(span);
                    }  
                    else 
                    {
                        visible(span);
                    }
                    
                    success = true;
                }
            }
            return success;
            
        } // function hourvalidation(hour, span)
        
       
        function datevalidation(span, date)
        {
            success = false;
            
            if (date.length == 0) 
            {
                hide(span);
            }
            else
            {
                if (date.length == 10)
                {
                    var day = date.substring(0, 2);
                    var month = date.substring(3, 5);
                    var year = date.substring(6);
                    var numberDay = 0;
                    
                    switch (month)
                    {
                        case '01': 
                        case '03':
                        case '05':
                        case '07':
                        case '08':
                        case '10':
                        case '12':
                            numberDay = 31;
                            break;
                        
                        case '04':
                        case '06':
                        case '09':
                        case '11':
                            numberDay=30;
                            break;
                            
                        case '02':
                            if (year %4 == 0) 
                                numberDay = 29;
                            else 
                                numberDay = 28;
                            break;
                    }
                    
                    if (numberDay == 0)
                    {
                        visible(span);
                    }
                    else
                    {
                        if (day <= numberDay) 
                        {
                            if (year >= 1900)
                            {
                                hide(span);                                   
                                success = true;
                            }
                            else
                            { 
                                visible(span);
                            }
                        }
                        else
                        { 
                            visible(span);
                        }
                        
                        if (success)
                        {
                            now = new Date();
                            
                            current = new Date();
                           
                            current.setFullYear(year,(month-1),day);
                            
                            if (current < now)
                            {
                                success = false;        
                                visible(span);
                            }
                        }
                    }
                }
            }
            return success;
            
        } // function datevalidation(span, date)
                        
        function getdatatime(data, time)
        {
            current = new Date();
            current.setFullYear(data.substring(6),data.substring(3, 5) - 1,data.substring(0, 2));
            current.setHours(time.substring(0, 2));
            current.setMinutes(time.substring(3, 5));
            current.setSeconds("00");
            current.setMilliseconds("00");
            return current;
        }
     
        function getdata(data)
        {
            current = new Date();
            current.setFullYear(data.substring(6),data.substring(3, 5) - 1,data.substring(0, 2));
            current.setHours("00");
            current.setMinutes("00");
            current.setSeconds("00");
            current.setMilliseconds("00");
            return current;
        }
                               
         function validate()
        {
             if ($("#ctl00_ContentHomePage_Frequency").is(":checked"))
             {
                var datedep = document.getElementById("ctl00_ContentHomePage_DepartureDate").value;
                var spandepd = document.all ? document.all["ctl00_ContentHomePage_ddValidator"] : document.getElementById("ctl00_ContentHomePage_ddValidator");
                var ddbool = datevalidation(spandepd, datedep);
                var datearr = document.getElementById("ctl00_ContentHomePage_ArriveDate").value;
                var spanarrd = document.all ? document.all["ctl00_ContentHomePage_adValidator"] : document.getElementById("ctl00_ContentHomePage_adValidator");
                var ardbool = datevalidation(spanarrd, datearr);
                if(ddbool&&ardbool){
                    getdepdate=getdata(datedep);
                    getarrdate=getdata(datearr);
                    if(getdepdate>=getarrdate){
                        visible(spandepd);
                        visible(spanarrd);
                    }
                }
                    
             }
             else{
        
                    var datedep = document.getElementById("ctl00_ContentHomePage_DepartureDate").value;
                    var spandepd = document.all ? document.all["ctl00_ContentHomePage_ddValidator"] : document.getElementById("ctl00_ContentHomePage_ddValidator");
                    var ddbool = datevalidation(spandepd, datedep);
                    var timedep = document.getElementById("ctl00_ContentHomePage_DepartureTime").value;
                    var spandept = document.all ? document.all["ctl00_ContentHomePage_dtValidator"] : document.getElementById("ctl00_ContentHomePage_dtValidator");
                    var dtbool = hourvalidation(timedep, spandept);
                    var datearr = document.getElementById("ctl00_ContentHomePage_ArriveDate").value;
                    var spanarrd = document.all ? document.all["ctl00_ContentHomePage_adValidator"] : document.getElementById("ctl00_ContentHomePage_adValidator");
                    var ardbool = datevalidation(spanarrd, datearr);
                    var timearr = document.getElementById("ctl00_ContentHomePage_ArriveHour").value;
                    var spandarrt = document.all ? document.all["ctl00_ContentHomePage_atValidator"] : document.getElementById("ctl00_ContentHomePage_atValidator");
                    var arrtbool = hourvalidation(timearr, spandarrt);
                    var dateexp = document.getElementById("ctl00_ContentHomePage_expdate").value
                    var spanexpd = document.all ? document.all["ctl00_ContentHomePage_expdvalidator"] : document.getElementById("ctl00_ContentHomePage_expdvalidator");
                    var expdbool = datevalidation(spanexpd, dateexp);
                    var timeexp = document.getElementById("ctl00_ContentHomePage_exptime").value;
                    var spanexpt = document.all ? document.all["ctl00_ContentHomePage_exptvalidator"] : document.getElementById("ctl00_ContentHomePage_exptvalidator");
                    var exptbool = hourvalidation(timeexp, spanexpt);
                    if (ddbool && dtbool)
                    {
                        now = new Date();
                        partenza = getdatatime(datedep, timedep);
                        
                        if (partenza < now)
                        {
                            visible(spandepd);
                            visible(spandept);
                        }
                    }
                     
                    if (ardbool && arrtbool)
                    {
                        now = new Date();
                        arrivo = getdatatime(datearr, timearr);
                        
                        if (arrivo < now)
                        {
                            visible(spanarrd);
                            visible(spandarrt);
                        }
                    } 
                      
                    if (ddbool && dtbool & ardbool & arrtbool)
                    {
                        partenza = getdatatime(datedep, timedep);
                        arrivo = getdatatime(datearr, timearr);
                        
                        if (arrivo <= partenza)
                        {
                            if (arrivo.getDate() == partenza.getDate() && 
                                partenza.getMonth() == arrivo.getMonth() && 
                                partenza.getFullYear() == arrivo.getFullYear())
                            {
                                visible(spandept);
                                visible(spandarrt);
                            }
                            else
                            {
                                visible(spandepd);
                                visible(spanarrd);
                            }
                        }
                    }
                    else
                    {
                        if (ddbool && ardbool)
                        {
                            partenza = getdata(datedep);
                            arrivo = getdata(datearr);
                            arrivo.setDate(datearr.substring(0, 2));
                    
                            if (arrivo < partenza)
                            {
                                visible(spandepd);
                                visible(spanarrd);
                            }
                        }
                    }
                    
                    if (expdbool && !exptbool)
                    {
                        var expdate = getdata(dateexp);
                        
                        if (ddbool)
                        { 
                            partenza = getdata(datedep);
                            
                            if (expdate > partenza)
                            {
                                visible(spandepd);
                                visible(spanexpd);
                            }
                        }
                        
                        if (ardbool)
                        { 
                            arrivo = getdata(datearr);
                            if (expdate > arrivo)
                            {
                                visible(spanarrd);
                                visible(spanexpd);
                            }
                        }
                    }
                    
                    if (expdbool && exptbool)
                    {
                        expdate = getdatatime(dateexp, timeexp);
                        now=new Date();
                        if(expdate<now){
                                visible(spanexpd);
                                visible(spanexpt);
                        } 
                        if (ddbool && dtbool)
                        {
                            
                            partenza = getdatatime(datedep,timedep);
                                
                            if (expdate > partenza)
                            {
                                visible(spandepd);
                                visible(spandept);
                                visible(spanexpd);
                                visible(spanexpt);
                            }
                        }
                        
                        if (ddbool && !dtbool)
                        {
                           
                            partenza = getdata(datedep);
                            expdate=getdata(dateexp);
                            if (expdate > partenza)
                            {
                                visible(spandepd);
                                visible(spanexpd);
                            }
                        }
                       
                        if(ardbool&&arrtbool) {
                            expdate = getdatatime(dateexp, timeexp);
                            arrivo = getdatatime(datearr,timearr);
                                    
                            if (expdate > arrivo)
                            {
                                visible(spanarrd);
                                visible(spandarrt);
                                visible(spanexpd);
                                visible(spanexpt);
                            }
                        }
                        if(ardbool&&!arrtbool){
                             arrivo = getdata(datearr);
                             expdate=getdata(dateexp);
                            if (expdate > arrivo)
                            {
                                visible(spanarrd);
                                visible(spanexpd);
                            }
                        }
                    }
              }
            
        }
          
    </script>
    <script type="text/javascript">
        function ShowHidediv(){
            var lbldepdate=document.getElementById('<%=lblDepartureDate.ClientID%>');
            var lblarrdate=document.getElementById('<%=lblArriveDate.ClientID%>');
            
            
            if ($("#ctl00_ContentHomePage_Frequency").is(":checked"))
            {
                $("div#frequencytrip").show("fast");
                document.getElementById('<%=DepartureTime.ClientID%>').style.display="none";
                document.getElementById('<%=lblDepartureTime.ClientID%>').style.display="none";
                document.getElementById('<%=lblArriveHour.ClientID%>').style.display="none";
                document.getElementById('<%=ArriveHour.ClientID%>').style.display="none";
                document.getElementById('<%=lblExpiration.ClientID%>').style.display="none";
                document.getElementById('<%=expdate.ClientID%>').style.display="none";
                document.getElementById('<%=lblExpirationTime.ClientID%>').style.display="none";
                document.getElementById('<%=exptime.ClientID%>').style.display="none";
                document.getElementById('<%=Image3.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow1.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow2.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow3.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow4.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow5.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow6.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow7.ClientID%>').style.display="none";
                document.getElementById('<%=hiderow8.ClientID%>').style.display="none";
                document.getElementById('show').style.display="";
                lbldepdate.innerHTML='<%= this.GetLocalResourceObject("Start")%>';
                lblarrdate.innerHTML='<%= this.GetLocalResourceObject("Stop")%>';
                
                
            }
            else{
                 $("div#frequencytrip").hide("fast");
                document.getElementById('<%=DepartureTime.ClientID%>').style.display="";
                document.getElementById('<%=lblDepartureTime.ClientID%>').style.display="";
                document.getElementById('<%=lblArriveHour.ClientID%>').style.display="";
                document.getElementById('<%=ArriveHour.ClientID%>').style.display="";
                document.getElementById('<%=lblExpiration.ClientID%>').style.display="";
                document.getElementById('<%=expdate.ClientID%>').style.display="";
                document.getElementById('<%=lblExpirationTime.ClientID%>').style.display="";
                document.getElementById('<%=exptime.ClientID%>').style.display="";
                document.getElementById('<%=Image3.ClientID%>').style.display="";
                document.getElementById('<%=hiderow1.ClientID%>').style.display="";
                document.getElementById('<%=hiderow2.ClientID%>').style.display="";
                document.getElementById('<%=hiderow3.ClientID%>').style.display="";
                document.getElementById('<%=hiderow4.ClientID%>').style.display="";
                document.getElementById('<%=hiderow5.ClientID%>').style.display="";
                document.getElementById('<%=hiderow6.ClientID%>').style.display="";
                document.getElementById('<%=hiderow7.ClientID%>').style.display="";
                document.getElementById('<%=hiderow8.ClientID%>').style.display="";
                document.getElementById('show').style.display="none";
                lbldepdate.innerHTML='<%=this.GetLocalResourceObject("lblDepartureDate.Text")%>';
                lblarrdate.innerHTML='<%= this.GetLocalResourceObject("lblArriveDate.Text")%>';
            }
            hide(document.getElementById('<%=ddValidator.ClientID%>'));
            hide(document.getElementById('<%=dtValidator.ClientID%>'));
            hide(document.getElementById('<%=adValidator.ClientID%>'));
            hide(document.getElementById('<%=atValidator.ClientID%>'));
            hide(document.getElementById('<%=expdvalidator.ClientID%>'));
            hide(document.getElementById('<%=exptvalidator.ClientID%>'));
            validate();
           
        
        }
    </script>
      
  
     
     
        


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentHomePage" runat="server">
    <h1>
        <asp:Localize runat="server" ID="WelcomeMessage" meta:resourcekey="title" />
    </h1>
    <cc1:DragPanelExtender ID="DragPanelExtender1" runat="server" TargetControlID="contentPanel"
        DragHandleID="headerPanel" />
    <div id="content_map_drag">
        <asp:Panel ID="contentPanel" runat="server" CssClass="Panel_move_map">
            <asp:Panel ID="headerPanel" runat="server">
                <div id="header_map">
                </div>
                <div id="content_map">
                    <div id="mapDiv">
                    </div>
                </div>
                <div id="footer_map">
                </div>
            </asp:Panel>
        </asp:Panel>
    </div>
    <div>
        <asp:UpdatePanel ID="vehiclepannel" runat="server">
            <ContentTemplate>
                <asp:Table runat="server" CssClass="formTable">
                    <asp:TableRow>
                        <asp:TableCell CssClass="formLabel">
                            <asp:Label ID="lblVehicle" runat="server" meta:resourcekey="lblVehicle"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell CssClass="formTextbox">
                            <asp:DropDownList ID="ddlvehicle" runat="server" CssClass="txtBox_generics" 
                                            onchange="InsertTrip(2)" onselectedindexchanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">
                            </asp:DropDownList>
                        </asp:TableCell>
                    </asp:TableRow>
                </asp:Table>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:Table ID="table" runat="server" CssClass="formTable">
           <asp:TableRow>
                <asp:TableCell ID="TableCell1" runat="server" CssClass="formLabel">
                            <asp:Label ID="lblDepartureAddress" runat="server" meta:resourcekey="lblDepartureAddress"></asp:Label>
                </asp:TableCell>
                <asp:TableCell ID="TableCell2" runat="server" CssClass="formTextbox">
                            <asp:TextBox ID="DepartureAddess" runat="server" CssClass="txtBox_generics" 
                                onchange="InsertTrip()" autocomplete="off"></asp:TextBox>
                            
                                
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow>
                <asp:TableCell ID="TableCell3" runat="server">
                            <asp:Label ID="lblArriveAddress" runat="server" meta:resourcekey="lblArriveAddress"></asp:Label>
                </asp:TableCell>
                <asp:TableCell ID="TableCell4" runat="server">
                            <asp:TextBox ID="ArriveAddress" runat="server" CssClass="txtBox_generics" 
                                onchange="InsertTrip()" autocomplete="off"></asp:TextBox>
                           
                </asp:TableCell>
            </asp:TableRow>
             <asp:TableRow>      
                        <asp:TableCell ID="TableCell5" runat="server"></asp:TableCell>
                        <asp:TableCell ID="TableCell6" runat="server">
                            <asp:HyperLink ID="BttnInsert" runat="server" NavigateUrl="javascript:InsertTrip()"
                                meta:resourcekey="BttnInsert" ></asp:HyperLink>
                        </asp:TableCell>
                </asp:TableRow>
       </asp:Table>
        <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
            <ContentTemplate>
                   
                <asp:Table ID="Table1" runat="server" CssClass="formTable">
                <asp:TableRow>
                        <asp:TableCell ID="TableCell7" runat="server" CssClass="formLabel">
                            <asp:Label ID="lblDraft" runat="server" meta:resourcekey="lblDraft"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell CssClass="formTextbox">
                            <asp:CheckBox ID="Draft" runat="server" CssClass="txtBox_generics" />
                        </asp:TableCell>
                        
                </asp:TableRow>
                 <asp:TableRow>
                    <asp:TableCell>
                        <asp:Label ID="lblFrequency" runat="server" meta:resourcekey="lblFrequency"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                    <asp:CheckBox ID="Frequency" runat="server" CssClass="txtBox_generics" onclick="ShowHidediv();" />
                    <input id="show" type="button" value="<%= this.GetGlobalResourceObject("TripLoaResource","showFrequency") %>" onclick="showPeriodicTripControl();" />
                    </asp:TableCell>
                 </asp:TableRow>
                 <asp:TableRow>
                    <asp:TableCell>
                        <asp:Label ID="periodicvalidator" runat="server" Style="color: Red;
                                font-size: 1pt; visibility: hidden"></asp:Label>
                    </asp:TableCell>
                 </asp:TableRow>
            <asp:TableRow>
                
               
                        <asp:TableCell runat="server">
                            <asp:Label ID="lblDepartureDate" runat="server" meta:resourcekey="lblDepartureDate"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:TextBox ID="DepartureDate" runat="server" CssClass="txtBox_generics" 
                                onchange="validate()" />
                            <cc1:CalendarExtender ID="DepartureDate_CalendarExtender" runat="server" TargetControlID="DepartureDate"
                                PopupButtonID="Image1" Format="dd/MM/yyyy" />
                            <cc1:MaskedEditExtender ID="DepartureDateMEExtender" runat="server" TargetControlID="DepartureDate"
                                Mask="99/99/9999" MaskType="Date" OnFocusCssClass="" OnInvalidCssClass="">
                            </cc1:MaskedEditExtender>
                            <asp:Image ID="Image1" runat="server" ImageUrl="~/common/Calendar_scheduleHS.png"
                                Height="16px" Width="16px" />
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell runat="server"></asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:Label ID="ddValidator" runat="server" meta:resourcekey="data" Style="color: Red;
                                font-size: 1pt; visibility: hidden"></asp:Label>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow ID="hiderow1" runat="server">
                        <asp:TableCell runat="server">
                            <asp:Label ID="lblDepartureTime" runat="server" meta:resourcekey="lblDepartureTime"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:TextBox ID="DepartureTime" runat="server"  CssClass="txtBox_generics"
                                onchange="validate()"></asp:TextBox>
                            <cc1:MaskedEditExtender ID="DepartureTimeMEExtender" runat="server" TargetControlID="DepartureTime"
                                Mask="99:99" MaskType="Time" OnFocusCssClass="Focus" OnInvalidCssClass="invalid">
                            </cc1:MaskedEditExtender>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow ID="hiderow2" runat="server">
                        <asp:TableCell runat="server"></asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:Label ID="dtValidator" runat="server" meta:resourcekey="ora" Style="color: Red;
                                font-size: 1pt; visibility: hidden"></asp:Label>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell runat="server">
                            <asp:Label ID="lblArriveDate" runat="server" meta:resourcekey="lblArriveDate"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:TextBox ID="ArriveDate" runat="server"  CssClass="txtBox_generics"
                                onchange="validate()"></asp:TextBox>
                            <asp:Image runat="server" ID="Image2" ImageUrl="~/common/Calendar_scheduleHS.png"
                                Height="16px" Width="16px" />
                            <cc1:CalendarExtender ID="ArriveDate_CalendarExtender" runat="server" TargetControlID="ArriveDate"
                                PopupButtonID="Image2" Format="dd/MM/yyyy">
                            </cc1:CalendarExtender>
                            <cc1:MaskedEditExtender ID="ArriveDateMEExtender" runat="server" TargetControlID="ArriveDate"
                                Mask="99/99/9999" MaskType="Date" OnFocusCssClass="Focus" OnInvalidCssClass="invalid">
                            </cc1:MaskedEditExtender>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow>
                        <asp:TableCell runat="server"></asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:Label ID="adValidator" runat="server" meta:resourcekey="data" Style="color: Red;
                                font-size: 1pt; visibility: hidden"></asp:Label>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow ID="hiderow3" runat="server">
                        <asp:TableCell runat="server">
                            <asp:Label ID="lblArriveHour" runat="server" meta:resourcekey="lblArriveHour"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:TextBox ID="ArriveHour" runat="server" CssClass="txtBox_generics"
                                onchange="validate()"></asp:TextBox>
                            <cc1:MaskedEditExtender ID="ArriveHourMEExtender" runat="server" TargetControlID="ArriveHour"
                                Mask="99:99" MaskType="Time" OnFocusCssClass="Focus" OnInvalidCssClass="invalid">
                            </cc1:MaskedEditExtender>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow ID="hiderow4" runat="server">
                        <asp:TableCell runat="server"></asp:TableCell>
                        <asp:TableCell runat="server">
                            <asp:Label ID="atValidator" runat="server" meta:resourcekey="ora" Style="color: Red;
                                font-size: 1pt; visibility: hidden"></asp:Label>
                        </asp:TableCell>
                    </asp:TableRow>
                     <asp:TableRow ID="hiderow5" runat="server">
                        <asp:TableCell  runat="server">
                            <asp:Label ID="lblExpiration" runat="server" meta:resourcekey="expiration"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell ID="TableCell25" runat="server">
                            <asp:TextBox ID="expdate" runat="server" CssClass="txtBox_generics" onchange="validate()"></asp:TextBox>
                            <asp:Image runat="server" ID="Image3" ImageUrl="~/common/Calendar_scheduleHS.png"
                                Height="16px" Width="16px" />
                            <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="expdate"
                                PopupButtonID="Image3" Format="dd/MM/yyyy">
                            </cc1:CalendarExtender>
                            <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="expdate"
                                Mask="99/99/9999" MaskType="Date" OnFocusCssClass="Focus" OnInvalidCssClass="invalid">
                            </cc1:MaskedEditExtender>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow ID="hiderow6" runat="server">
                        <asp:TableCell  runat="server"></asp:TableCell>
                        <asp:TableCell  runat="server">
                            <asp:Label ID="expdvalidator" runat="server" meta:resourcekey="data" Style="color:Red; font-size: 1pt; visibility: hidden"></asp:Label>
                            
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow ID="hiderow7" runat="server">
                        <asp:TableCell runat="server">
                            <asp:Label ID="lblExpirationTime" runat="server" meta:resourcekey="exptime"></asp:Label>
                        </asp:TableCell>
                        <asp:TableCell  runat="server">
                            <asp:TextBox ID="exptime" runat="server" CssClass="txtBox_generics"
                                onchange="validate()"></asp:TextBox>
                            <cc1:MaskedEditExtender ID="MaskedEditExtender2" runat="server" TargetControlID="exptime"
                                Mask="99:99" MaskType="Time" OnFocusCssClass="Focus" OnInvalidCssClass="invalid">
                            </cc1:MaskedEditExtender>
                        </asp:TableCell>
                    </asp:TableRow>
                    <asp:TableRow ID="hiderow8" runat="server">
                        <asp:TableCell  runat="server"></asp:TableCell>
                        <asp:TableCell  runat="server">
                            <asp:Label ID="exptvalidator" runat="server" meta:resourcekey="ora" Style="color: Red;
                                font-size: 1pt; visibility: hidden"></asp:Label>
                        </asp:TableCell>
                    </asp:TableRow>
                    
                    
                
                </asp:Table>
             </ContentTemplate>
             </asp:UpdatePanel>     
                
              
           
        
        
                    <asp:UpdatePanel ID="controllo" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <TestAscx:ExampleControl ID="ExampleControl_1"  runat="server" />
                        </ContentTemplate>
                    </asp:UpdatePanel>
                     <div id="frequencytrip" style="display:none"  >
                   
                   
                
                        <uc1:PeriodicTrip ID="ptc" Editable="true" runat="server" />
                   
                 </div>  
        
        
        <div id="Pulsanti">
            <br />
            <asp:UpdatePanel ID="up_button" runat="server">
                <ContentTemplate>
                    <%--
                        <GeoRef: Michele>
                        Il controllo adesso esegue la sincronizeLOAMapControl automaticamente... ma si deve 
                        specificare l'id del controllo che vuol trovare il geotrip editato nel code behind dopo una onClick
                        Si possono settare più controlli, gli di devono essere separati da ";"
                        --%>
                    <map:LOAMap ID="map_1" runat="server" MapDiv="mapDiv" ZoomLevel="10" TargetControlIDs="ctl00_ContentHomePage_BtnCreate" Editable="true" />
                     <script type="text/javascript">
                         mapStrings["add_destination"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuAddDest") %>';
                        mapStrings["remove_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuRemTrip") %>';
                        mapStrings["select_vehicle"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuSelVehicle") %>';
                        mapStrings["insert_waypoint"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuInsWay") %>';
                        mapStrings["take_in_passenger"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuTakeInPass") %>';
                        mapStrings["take_off_passenger"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuTakeOffPass") %>';
                        mapStrings["detach_passenger"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuDetachPass") %>';
                        mapStrings["detach_from_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoMenuDetachTrip") %>';
                        
                        
                        mapStrings["start_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeosInfoRoute") %>';
                        mapStrings["startDescr_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeosDescrInfoRoute") %>';
                        mapStrings["end_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoeInfoRoute") %>';
                        mapStrings["endDescr_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoeDescrInfoRoute") %>';
                        mapStrings["dist_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoDistInfoRoute") %>';
                        mapStrings["time_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoTimeInfoRoute") %>';
                        mapStrings["wayNumb_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeonWayInfoRoute") %>';
                        mapStrings["title_info_route"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoTitleInfoRoute") %>';
                        
                        mapStrings["start_info_trip"]='<%=this.GetGlobalResourceObject("TripLoaResource","GeosInfoTrip") %>';
                        mapStrings["startDescr_info_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeosDescrInfoTrip") %>';
                        mapStrings["end_info_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoeInfoTrip") %>';
                        mapStrings["endDescr_info_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoeDescrInfoTrip") %>';
                        mapStrings["dist_info_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoDistInfoTrip") %>';
                        mapStrings["time_info_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoTimeInfoTrip") %>';
                        mapStrings["routeN_info_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeonRoutesInfoTrip") %>';
                        mapStrings["title_info_trip"]='<%= this.GetGlobalResourceObject("TripLoaResource","GeoTitleInfoTrip") %>';
                        
                        mapStrings["endLabel_trip"]='<%=this.GetGlobalResourceObject("TripLoaResource","GeoEndLabel") %>';
                        mapStrings["end_trip"]='<%=this.GetGlobalResourceObject("TripLoaResource","GeoEndTrip") %>';
                        mapStrings["endDescr_trip"]='<%=this.GetGlobalResourceObject("TripLoaResource","GeoEndDescr") %>';

                        mapStrings["waypointLabel"]= '<%=this.GetGlobalResourceObject("TripLoaResource","GeoWayLabel") %>';
                        mapStrings["waypoint_Location"]='<%=this.GetGlobalResourceObject("TripLoaResource","GeoWayLoc") %>';
                        mapStrings["waypoint_Descr"]='<%=this.GetGlobalResourceObject("TripLoaResource","GeoWayDescr") %>';
                        
                        mapStrings["passengers_in"]  ='<%= this.GetGlobalResourceObject("TripLoaResource","GeoPassIn") %>';
                        mapStrings["passengers_off"] ='<%= this.GetGlobalResourceObject("TripLoaResource","GeoPassOff") %>';
                    </script>
                    <asp:Button ID="BtnCreate" runat="server" meta:resourcekey="BtnCreate" Width="215px"
                        Height="32px" OnClick="BtnCreate_Click" CausesValidation="false"
                        UseSubmitBehavior="true" />
                    <asp:Button ID="BtnCancel" runat="server" Height="32px" Width="186px"
                        meta:resourcekey="BtnCancel" OnClick="BtnCancel_Click" CausesValidation="false" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </div>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            <img alt="Loading please wait" src="../master/resourcesNew/img/loader.gif" />
           <asp:Label ID="lbl_loader" runat="server" CssClass="lbl_strong" meta:resourcekey="lbl_loader"></asp:Label>
        </ProgressTemplate>
    </asp:UpdateProgress>
    <!-- added by georef -->

    <script type="text/javascript">
        Sys.Application.add_load(bindMapEvents);
        var arriveId = "<%=ArriveAddress.ClientID %>";
          GUI.AAAGeoCodingMenu(document.getElementById(arriveId));
         document.getElementById(arriveId).geocodeFail='<%= this.GetGlobalResourceObject("TripLoaResource","GeocodFail") %>';
         document.getElementById(arriveId).locNotFound='<%= this.GetGlobalResourceObject("TripLoaResource","LocFail") %>';
         var departureId = "<%=DepartureAddess.ClientID %>";
         GUI.AAAGeoCodingMenu(document.getElementById(departureId), GUI.AAAGeoCodingMenu.RIGHT, GUI.AAAGeoCodingMenu.UP);
         document.getElementById(departureId).geocodeFail='<%= this.GetGlobalResourceObject("TripLoaResource","GeocodFail") %>';
         document.getElementById(departureId).locNotFound='<%= this.GetGlobalResourceObject("TripLoaResource","LocFail") %>';
       
        
        
        function draw(event) {
            if (event.controlStatus == GUI.AAAGeoCodingMenu.READY || event.controlStatus == GUI.AAAGeoCodingMenu.ERROR) {
                if ((event.target.id == departureId) && (document.getElementById(departureId).GetStatus() == GUI.AAAGeoCodingMenu.READY))
                    InsertTrip(0);
                else
                    InsertTrip(1);
            }
            else{
                if(event.controlStatus= GUI.AAAGeoCodingMenu.EMPTY)
                {
                    var loamap = Sys.Application.findComponent("ctl00_ContentHomePage_map_1");
                    loamap.getGMap().clearEditableTrip();
                }
            }
        };
        
        document.getElementById(arriveId).statusHandler(draw);
        document.getElementById(departureId).statusHandler(draw);
        ShowHidediv();
    </script>
    <!-- end add -->
</asp:Content>
